import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports: ['vue', 'vue-router']//自动导入vue和vue-router相关api
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    proxy: {
      '/visitor': {//物业管理代理
        target: 'http://101.42.253.49',
        changeOrigin: true
      },
      '/device': {//物业管理-设备管理-设备列表
        target: 'http://101.42.253.49',
        changeOrigin: true
      },
      '/devicewarn': {//物业管理-设备管理-设备告警表
        target: 'http://101.42.253.49',
        changeOrigin: true
      },
      '/devicerepair': {//物业管理-设备管理-设备维修记录表
        target: 'http://101.42.253.49',
        changeOrigin: true
      },
      '/vehicle': {
        target: 'http://101.42.253.49',//目标服务器
        changeOrigin: true,//开启跨域
      },
      '/warningrule': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      // 项目管理
      '/project': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      // 登录
      '/User': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      '/tenantBillingTable': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      '/tenantInformationTable': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      '/tenantPersonnelTable': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      '/vehicleBillTable': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
      '/sourcedetail': {
        target: "http://101.42.253.49",
        changeOrigin: true,
      },
    }
  },
})
